local queque = fk.CreateSkill{
  name = "hanqing__queque",
  tags = { Skill.Compulsory },
}

Fk:loadTranslationTable{
  ["hanqing__queque"] = "却却",
  [":hanqing__queque"] = "锁定技，当你造成伤害后，你需弃置一张手牌，或失去一个技能直到本回合结束。",

  ["#hanqing__queque-discard"] = "却却：弃置一张手牌，或点“取消”失去一个技能直到本回合结束",
  ["#hanqing__queque-choice"] = "却却：失去一个技能直到回合结束",
}

queque:addEffect(fk.Damage, {
  anim_type = "negative",
  on_use = function (self, event, target, player, data)
    local room = player.room
    local turn_event = room.logic:getCurrentEvent():findParent(GameEvent.Turn)
    if #room:askToDiscard(player, {
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = queque.name,
      cancelable = turn_event ~= nil,
      prompt = "#hanqing__queque-discard",
    }) == 0 and turn_event then
      local choice = room:askToCustomDialog(player, {
        skill_name = queque.name,
        qml_path = "packages/utility/qml/ChooseSkillBox.qml",
        extra_data = { player:getSkillNameList(), 1, 1, "#hanqing__queque-choice", {} },
      })
      if choice == "" then
        choice = table.random(player:getSkillNameList())
      else
        choice = json.decode(choice)[1]
      end
      turn_event:addCleaner(function()
        room:handleAddLoseSkills(player, choice)
      end)
      player.room:handleAddLoseSkills(player, "-"..choice)
    end
  end,
})

return queque
